home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STREAMS.SWG / 0002_STREAMS2.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  33 lines

  1. {
  2. > I would like to start on a Program that reads a certain File.  The
  3. > problem is that the Records are of different lenghts.  The File
  4. > structure is as follows: One File contains the header For each Record
  5. > which is kept in a seperate File. The header has a Word Variable which
  6. > is the size of the Record in the other File.  It also has a Integer
  7. > With points to the Record number in the other File.
  8.  
  9. The easiest way is to use streams.  Here's a sketch:
  10.  
  11. }
  12.  
  13. Uses
  14.   Objects;
  15.  
  16. Var
  17.   S : TDosStream;
  18.   data : Array[1..1000] of Byte;   { Big enough For anything }
  19.   Position : LongInt;              { The position of the item }
  20.   Size : Word;                     { The size of the item }
  21. begin
  22.   S.init('dataFile',stOpenRead);
  23.  
  24.  { Now determine Position and Size from the other File somehow }
  25.  
  26.   S.Seek(Position);
  27.   S.Read(data,Size);
  28.   if S.Status <> stOK then
  29.   begin
  30.     Writeln('Stream error ',S.Status,' With error info ',S.ErrorInfo);
  31.     S.Reset;
  32.   end;
  33. end.